package com.ffzl.cloud.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.ffzl.cloud.R;
import com.ffzl.cloud.app.AppAdapter;
import com.ffzl.cloud.http.glide.GlideApp;
import com.ffzl.cloud.http.response.GrideviewItem;

import java.util.List;

public class GrideViewAdapter extends AppAdapter<List<GrideviewItem>> {
    private final List<GrideviewItem> mSelectVideo;

    public GrideViewAdapter(Context context, List<GrideviewItem> mSelectVideo) {
        super(context);
        this.mSelectVideo = mSelectVideo;
    }

    @Override
    public int getItemCount() {
        return mSelectVideo.size();
    }

    @NonNull
    @Override
    public GrideViewAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new GrideViewAdapter.ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private final LinearLayout grideview_main_linear;
        private final ImageView grideview_main_img;
        private final TextView grideview_main_txt;
        private final TextView grideview_main_txt2;

        private ViewHolder() {
            super(R.layout.grideview_main_item);
            grideview_main_linear = findViewById(R.id.grideview_main_linear);
            grideview_main_img = findViewById(R.id.grideview_main_img);
            grideview_main_txt = findViewById(R.id.grideview_main_txt);
            grideview_main_txt2 = findViewById(R.id.grideview_main_txt2);

        }

        @Override
        public void onBindView(int position) {
            //mTextView.setText(getItem(position));
//            GlideApp.with(getContext())
//                    .load(getItem(position))
//                    .into(grideview_main_img);
            grideview_main_img.setImageDrawable(mSelectVideo.get(position).getBitmapItem());
            grideview_main_txt.setText(mSelectVideo.get(position).getNameItem());
            grideview_main_txt2.setText(mSelectVideo.get(position).getNameValue());
        }
    }

}